package com.paas.form.queue;

import com.paas.common.web.exception.OperException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class FormApiServerFactoryBean implements InitializingBean{
	@Autowired
	private FormApilogConsumer formApiConsumer;
	
	private FormApilogServer formApiServer;
	
	@Override
	public void afterPropertiesSet() throws Exception {
		if(formApiServer==null){
			formApiServer =  FormApilogServer.getInstance();
		}
		if(formApiConsumer!=null){
			formApiServer.setFormApiConsumer(formApiConsumer);
			formApiServer.start();
		}else{
			//TODO 如果没有则需要提示未提供生产者
			throw new OperException("没有服务提供者[operLogConsumer]");
		}
	}
}
